import { actionTypes } from '../store'
import axios from 'axios'

const setData=(value)=>({
    type:actionTypes.CHANGE_HOME_INFO,
    value,
    totalPage:Math.ceil(value.Writer.length/6)
});

const setMoreData=(value)=>({
    type:actionTypes.ADD_LIST,
    value
});

export const getHomeInfo=()=>{
    return(dispatch)=>{
        axios.get('/api/home.json').then((res)=>{
            const data=res.data.data;
            dispatch(setData(data))
        }).catch((err)=>{
                console.log(err)
        })
    }
};
export const getMore=()=>{
    return(dispatch)=>{
        axios.get('/api/homeList.json').then((res)=>{
            const data=res.data.data;
            dispatch(setMoreData(data))
        }).catch((err)=>{
                console.log(err)
        })
    }
};
export const getAuthor=(value)=>({
    type:actionTypes.GET_AUTHOR,
    value
});




